<script>
	export default {
		onLaunch: function() {
			uni.hideTabBar()
			console.log(process.env.VUE_APP_BASE_URL);
			console.warn('当前组件仅支持 uni_modules 目录结构 ，请升级 HBuilderX 到 3.1.0 版本以上！')
			console.log('App Launch')
			if((uni.store.getters.uid ?? '') == '') {
				uni.store.commit('GET_STORE')
			}
			// #ifdef MP
			const updateManager = uni.getUpdateManager();
			updateManager.onCheckForUpdate(res => {
				if(res.hasUpdate) {
					updateManager.onUpdateReady(() => {
						updateManager.applyUpdate()
					})
				}
			})
			// #endif
			// #ifdef APP
			const { appVersionCode, osName } = uni.getSystemInfoSync()
			const params = {
				versionCode: appVersionCode,
				platform: osName
			}
			this.$request.post('/upgrade/checkVersion', params).then(res => {
				if(res.code === 200) {
					if(res.data.hasUpdate) {
						uni.navigateTo({
							url: `/pages/common/upgrade?item=${JSON.stringify(res.data)}`,
						})
					}
				}
			})
			// #endif
			const username = uni.$store.get('username')
			const password = uni.$store.get('password')
			if((username ?? '') != '' && (password != '') != '') {
				this.$request.post('/login', {
					username,
					password
				}).then(res => {
					if(res.code === 200) {
						uni.store.dispatch('getInfo')
						uni.reLaunch({
							url: '/pages/tabs/index'
						})
					}
				})
			}
		},
		onShow: function() {
			uni.hideTabBar()
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/uni_modules/uni-scss/index.scss';
	/* #ifndef APP-NVUE */
	@import '@/static/customicons.css';
	/* 引入uView样式 */
	@import "@/uni_modules/uview-ui/index.scss";
	/* iconfont */
	
	// 设置整个项目的背景色
	page {
		background-color: #FFFFFF;
		color: #232832;
	}
	/* #endif */
	
	.page {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		background-color: #FFFFFF;
		
		/* #ifndef APP-NVUE */
		overflow-y: auto;
		&::v-deep .z-paging-content {
			top: inherit;
			bottom: inherit;
		}
		/* #endif */
		.placeholder-bar-bottom {
			width: 100%;
			height: 30px;
		}
	}
</style>
